home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ETO Development Tools 4
/
ETO Development Tools 4.iso
/
Essentials
/
C++ A'Link Files
/
1989
/
0003-RE C++ Stand Alone C-Nov89
< prev
next >
Wrap
Text File
|
1991-03-06
|
1KB
|
46 lines
Item forwarded by CPLUS.ADMIN to CP.ARCHIVES
Item 0888993 21-Nov-89 10:40
From: PALEVICH1 Palevich, John
To: CPLUS.APPLE$ C++ Interest List--Apple Employees
Sub: RE: C++ Stand Alone Code
If you want virtual functions in stand alone C++ code, it is possible to have
them. The problem is that the MPW run time global data initialization code
isn't able to initialize global variables to point to addresses of functions.
Instead it tries to point at A5-relative offsets, which only apply to CODE
segments.
There are several ways around this problem:
1) Don't use virtual functions.
2) Ask the MPW guys to enhance the data initialization code (would require
changes to the linker and the C run time library.)
3) Edit the output of CFront to initialize the virtual function tables using C
code at run time.
I myself have used option 1, but if I were gung-ho, I would use StreamEdit
scripts to edit the output of CFront, and turn phrases like this:
void* TFoo_vtable[10] = { _dt_TFoo, TFoo_A, TFoo_B ... };
into something like this:
void* TFoo_vtable[10];
TFooInit() {
TFoo_vtable[0] = _dt_TFoo;
TFoo_vtable[1] = TFoo_A;
TFoo_vtable[2] = TFoo_B;
... etc ...
}
Then my main() module would have to call TFooInit() before using TFoo objects.
Jack Palevich